import * as echarts from 'echarts';
import {barEcharts, pie} from "@/components/index/indexEchartsInter";
type EChartsOption = echarts.EChartsOption;

//左部柱状图
function getBar(bar:barEcharts|undefined) {
    // console.log(bar)
    var myChart = echarts.init(document.getElementById('barMain')!);
    var option: EChartsOption;
    option = {
        xAxis: {
            type: 'category',
            data: bar?.collageName
        },
        yAxis: {
            type: 'value'
        },
        color:'#68BBC4',
        series: [
            {
                data: bar?.consultBy,
                type: 'bar'
            }
        ]
    };
    option && myChart.setOption(option);
}

//右部性别图
function getPieSex(pie:pie) {
    var myChart = echarts.init(document.getElementById('pieMainSex')!);
    var option: EChartsOption;
    option = {
        tooltip: {
            trigger: 'item'
        },
        color:['#5087EC','#68BBC4'],
        series: [
            {
                type: 'pie',
                radius: '60%',
                data: [
                    { value: pie.man, name: '男' },
                    { value: pie.woman, name: '女' },
                ],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    option && myChart.setOption(option);
}
//右部学历图
function getPieDegree(pie:pie) {
    var myChart = echarts.init(document.getElementById('pieMainDegree')!);
    var option: EChartsOption;
    option = {
        tooltip: {
            trigger: 'item'
        },
        color:['#5087EC','#68BBC4'],
        series: [
            {
                type: 'pie',
                radius: '60%',
                data: [
                    { value: pie.bachelor, name: '本科生' },
                    { value: pie.master, name: '研究生' }
                ],
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }
        ]
    };
    option && myChart.setOption(option);
}
export {getBar,getPieSex,getPieDegree}
